package cn.zn.log.service.impl;

import cn.zn.log.entity.SysOperateLog;
import cn.zn.log.mapper.SysOperateLogMapper;
import cn.zn.log.service.SysOperateLogService;
import cn.zn.log.vo.SysOperateLogPageVo;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Arrays;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author zn-admin
 * @since 2021-01-28
 */
@Service
public class SysOperateLogServiceImpl extends ServiceImpl<SysOperateLogMapper, SysOperateLog> implements SysOperateLogService {

    @Override
    public void insertOperateLog(SysOperateLog operateLog) {
        baseMapper.insert(operateLog);
    }

    @Override
    public Object selectOperateLogList(SysOperateLogPageVo vo) {
        if (!vo.getPage()) {
            return baseMapper.selectOperateLogList(vo);
        }

        Page<SysOperateLog> page = new Page<>(vo.getCurrent(), vo.getSize());
        return baseMapper.selectOperateLogList(page, vo);
    }

    @Override
    public void deleteOperateLogByIds(String[] operateIds) {
        baseMapper.deleteBatchIds(Arrays.asList(operateIds));
    }

    @Override
    public void cleanOperateLog() {
        baseMapper.cleanOperateLog();
    }

}
